package cn.wgx.module.sys.mapper;


import cn.wgx.common.base.IBaseMapper;
import cn.wgx.common.entity.sys.Permission;
import cn.wgx.common.entity.sys.Role;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface RoleMapper extends IBaseMapper<Role> {

    @Select("select  r.*  from sys_role r " +
            "inner join sys_role_user ru on r.role_id = ru.role_id " +
            "where ru.user_id = #{userId}")
    Set<Role> findRolesByUserId(Integer userId);

    @Select("SELECT sp.* FROM `sys_permission` sp " +
            "inner join sys_role_permission rp " +
            "on sp.permission_id = rp.permission_id " +
            "inner join sys_role sr " +
            "on rp.role_id = sr.role_id " +
            "where rp.role_id = #{role_id}")
    Set<Permission> findPersByRole(Integer role_id);
}
